/**
 * Dear programmer:
 * When I wrote this code, only god and I knew how it worked.
 * Now, only god knows it!
 *
 * @author: Pegasus  Date: 2018/11/24 Time: 15:41
 */

import {GetRetrieveCacheData} from "./_Actions"
import {FetchStatus} from "../../configuration/RequestConfiguration"

/**
 * 获取本地缓存数据
 * @param state
 * @param action
 * @returns {{fetchStatus: *}}
 */
export const onRetrieveCacheData = (state = {}, action) => {
  switch (action.type) {
    case GetRetrieveCacheData: {
      switch (action.status) {
        case FetchStatus.Start: {
          return {fetchStatus: action.status};
        }
        case FetchStatus.Success: {
          return {...action.json, fetchStatus: action.status};
        }
        default: {
          return {...state, fetchStatus: action.status}
        }
      }
    }
  }
  return state
}

/**
 * 返回格式
 * @type {{MSG: string, area: *[], RETURN: string, common: Array, user: *[], object: *[]}}
 */
let CacheData = {
  "RETURN":"1",
  "MSG":"OK",
  "area":[
  {
    "sn":"1",
    "name":"主楼",
    "shortcut":"ZL",
    "fullname":"主楼;",
    "level":"1",
    "node":"D"
  },
  {
    "sn":"1.1",
    "name":"一层",
    "shortcut":"YC",
    "fullname":"主楼;一层;",
    "level":"2",
    "node":"D"
  },
  {
    "sn":"1.1.1",
    "name":"走廊",
    "shortcut":"ZL",
    "fullname":"主楼;一层;走廊;",
    "level":"3",
    "node":"I"
  },
  {
    "sn":"1.10",
    "name":"测试",
    "fullname":"主楼;测试;",
    "level":"2",
    "node":"I"
  },
  {
    "sn":"1.2",
    "name":"二层",
    "shortcut":"EC",
    "fullname":"主楼;二层;",
    "level":"2",
    "node":"I"
  },
  {
    "sn":"2",
    "name":"室外",
    "shortcut":"SW",
    "fullname":"室外;",
    "level":"1",
    "node":"D"
  },
  {
    "sn":"2.1",
    "name":"停车场",
    "shortcut":"TCC",
    "fullname":"室外;停车场;",
    "level":"2",
    "node":"I"
  },
  {
    "sn":"3",
    "name":"副楼",
    "shortcut":"FL",
    "fullname":"副楼;",
    "level":"1",
    "node":"D"
  },
  {
    "sn":"3.1",
    "name":"一层",
    "shortcut":"YC",
    "fullname":"副楼;一层;",
    "level":"2",
    "node":"I"
  },
  {
    "sn":"3.2",
    "name":"二楼",
    "shortcut":"EL",
    "fullname":"副楼;二楼;",
    "level":"2",
    "node":"I"
  }
],
  "object":[
  {
    "sn":"1",
    "name":"设备",
    "shortcut":"SB",
    "fullname":"设备;",
    "level":"1",
    "node":"D"
  },
  {
    "sn":"1.1",
    "name":"电器设备",
    "shortcut":"DQSB",
    "fullname":"设备;电器设备;",
    "level":"2",
    "node":"D"
  },
  {
    "sn":"1.1.1",
    "name":"电视机",
    "shortcut":"DSJ",
    "fullname":"设备;电器设备;电视机;",
    "level":"3",
    "node":"I"
  },
  {
    "sn":"1.1.2",
    "name":"空调",
    "shortcut":"KD",
    "fullname":"设备;电器设备;空调;",
    "level":"3",
    "node":"I"
  },
  {
    "sn":"1.2",
    "name":"厨房用品",
    "shortcut":"CFYP",
    "fullname":"设备;厨房用品;",
    "level":"2",
    "node":"D"
  },
  {
    "sn":"1.2.1",
    "name":"电风扇",
    "shortcut":"DFS",
    "fullname":"设备;厨房用品;电风扇;",
    "level":"3",
    "node":"I"
  },
  {
    "sn":"1.2.2",
    "name":"烤箱",
    "shortcut":"KX",
    "fullname":"设备;厨房用品;烤箱;",
    "level":"3",
    "node":"I"
  },
  {
    "sn":"1.3",
    "name":"维修配件",
    "shortcut":"WXPJ",
    "fullname":"设备;维修配件;",
    "level":"2",
    "node":"I"
  },
  {
    "sn":"2",
    "name":"家具",
    "shortcut":"JJ",
    "fullname":"家具;",
    "level":"1",
    "node":"D"
  },
  {
    "sn":"2.1",
    "name":"床",
    "shortcut":"C",
    "fullname":"家具;床;",
    "level":"2",
    "node":"I"
  },
  {
    "sn":"2.2",
    "name":"沙发",
    "shortcut":"SF",
    "fullname":"家具;沙发;",
    "level":"2",
    "node":"I"
  },
  {
    "sn":"3",
    "name":"装修",
    "shortcut":"ZX",
    "fullname":"装修;",
    "level":"1",
    "node":"D"
  },
  {
    "sn":"3.1",
    "name":"墙壁",
    "shortcut":"QB",
    "fullname":"装修;墙壁;",
    "level":"2",
    "node":"I"
  },
  {
    "sn":"3.2",
    "name":"地板",
    "shortcut":"DB",
    "fullname":"装修;地板;",
    "level":"2",
    "node":"I"
  }
],
  "common":[

],
  "user":[
  {
    "userid":"L01",
    "username":"华盛运维",
    "phone":"131123456",
    "phone_short":"45825",
    "depart":"001",
    "depart_name":"营销部"
  },
  {
    "userid":"L02",
    "username":"周晶（副总）",
    "phone":"132554584",
    "phone_short":"56465",
    "depart":"002",
    "depart_name":"房务部"
  },
  {
    "userid":"l22",
    "username":"666",
    "phone":"1651897",
    "phone_short":"55666",
    "depart":"001",
    "depart_name":"营销部"
  },
  {
    "userid":"LZY",
    "username":"李镇源（总经理）",
    "depart":"001",
    "depart_name":"营销部"
  },
  {
    "userid":"SY00",
    "username":"王星（稽核）",
    "depart":"001",
    "depart_name":"营销部"
  },
  {
    "userid":"SY01",
    "username":"前台收银",
    "depart":"001",
    "depart_name":"营销部"
  }
]
}